package orders

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"order_srv/orderclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type InvoiceReviewLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewInvoiceReviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InvoiceReviewLogic {
	return &InvoiceReviewLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// InvoiceReview 发票审核
func (l *InvoiceReviewLogic) InvoiceReview(req *types.InvoiceReviewRequest) (resp *types.Response, err error) {
	// 业务逻辑
	order, err := l.svcCtx.OrderRpc.InvoiceReview(l.ctx, &orderclient.InvoiceReviewRequest{
		OrderSn:      req.OrderSn,
		ReviewerId:   req.ReviewerId,
		Status:       req.Status,
		ReviewerNote: req.ReviewerNote,
	})
	if err != nil {
		return respons.Error(400, "服务端错误", err.Error()), err
	}
	return respons.Success(order), nil
}
